<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>改变样式</title>
	<style type="text/css">
        #box{
        	width:200px;height:200px;background: pink;
        }


	</style>
	<script type="text/javascript">
        //设置定时器让div缓慢增大   1秒执行一次   并包含停止
        
        
        
        //获取图片的宽高
        var width=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;			

		var height=window.innerHeight  || document.documentElement.clientHeight || document.body.clientHeight;
		
		//转整数
		width = parseInt(width); //1502px
		alert(width);    
        height = parseInt(height); 
        
        //设置标准方向
        direction = 0;
        function run(){
            if(direction == 0){
           	    width += 10;
           	    height += 10;
            }else{
            	width -= 10;
            	height -= 10;
            }

            if( height == '400px'){
                direction = 1;
            }else if(height == '200px'){
            	direction = 0;
            }

            box.style.width = width + 'px';
            box.style.height = height + 'px';
        }

        window.onload = function(){
        	var box = document.getElementById('box');
        	var clock = document.getElementById('btn');      	
        	clock.onclick = function(){
        		if(clock.getAttribute('value')=='start'){
                    clock.setAttribute('value', 'stop');
                    time = setInterval(run,1000);
        		}else{
        			clock.setAttribute('value','start');
        			clearInterval(time);
        		}
        	}
        }



	</script>
</head>
<body>
    <input id="btn" type="button" value="start">
    <div id="box"></div>

    <script type="text/javascript">
    //加点击事件，移到他上面时变大，移除他上面时变小
    
    //     var oBox = document.getElementById('box');
    //     oBox.onmouseover = function(){
    //     	oBox.style.width = '400px';
    //     	oBox.style.height = '400px';
    //     	oBox.style.background = 'red';
    //     }
        
    //     oBox.onmouseout = function (){
    //     	oBox.style.width = '200px';
    //     	oBox.style.height = '200px';
    //     	oBox.style.background = 'pink';
    //     }



    // </script>
	
</body>
</html>